package main;

import enumeration.RobStrategy;
import mysql.MysqlUtil;
import user.User;
import java.util.*;

public class robClass {
    public static int num = 10;
    public static int robMode = 1;  //0 体育课 1 公选课
    private static ArrayList<User> users = MysqlUtil.getAllUser();
    //手动实现一个AOP才对。。。 每次收到包后进行拦截


    public static User register(User user) {
        user = new User();
        Scanner strInput = new Scanner(System.in, "UTF-8");
        System.out.println(strInput);

        System.out.println("=========================================填写个人信息=========================================");
        System.out.println("正方账号:");
        if (strInput.hasNext()) user.setUsername(strInput.next());
        System.out.println("正方密码:");
        if (strInput.hasNext()) user.setPassword(strInput.next());
        System.out.println("真实名字:");
        if (strInput.hasNext()) user.setStudentName(strInput.next());
        System.out.println("每秒线程数量:");
        if (strInput.hasNext()) user.setThreads(Integer.valueOf(strInput.next()));
        user.setRobEnable(1);
        System.out.println("开始抢课时间:");
        System.out.println("格式: 2020-11-29 18:50:00");
        System.out.println("默认请输入0 即现在开始");
        strInput.close();
        Scanner dateInput = new Scanner(System.in, "UTF-8");
        if (dateInput.hasNextLine()) {
            //Date date = new Date();
            String dateStr = dateInput.nextLine();
            if (Integer.valueOf(dateStr) != 0) {
                user.setStartTime(dateStr);
//                String ymd = dateStr.split("\\s+")[0];
//                String[] ymd2 = ymd.split("-");
//                String time = dateStr.split("\\s+")[1];
//                String[] time2 = time.split("\\s+");
//
//                int year = Integer.parseInt(ymd2[0]);
//                int month = Integer.parseInt(ymd2[1]);
//                int day = Integer.parseInt(ymd2[2]);
//
//                int hour = Integer.parseInt(time2[0]);
//                int min = Integer.parseInt(time2[1]);
//                int second = Integer.parseInt(time2[2]);
//
//                date.setYear(year);
//                date.setMonth(month);
//                date.setDate(day);
//                date.setHours(hour);
//                date.setMinutes(min);
//                date.setSeconds(second);
//
//                System.out.println("设置的时间为: ");

//                System.out.println(date.toString());
            }
//            user.setStartTime((java.sql.Date) date);
            System.out.println(user.getStartTimeDate());
        }

        System.out.println("==============================================================================================");

        User.userCache.put(user.getUsername(), user);
        MysqlUtil.updateUser(user);

        System.out.println(user);
        dateInput.close();
        showTable(user);
        return user;
    }

    public static void showTable(User user) {


        System.out.println("=================挖田系统=================");
        System.out.println("1.填写个人信息");
        System.out.println("2.选择体育课程");
        System.out.println("3.定时体育抢课");
        System.out.println("4.开始体育抢课");
        System.out.println("5.暂停体育抢课");
        System.out.println("6.全体开始体育定时抢课");
        System.out.println("7.全体暂停体育定时抢课");
        System.out.println("8.全体开始体育抢课");
        System.out.println("9.全体暂停体育抢课");

        System.out.println("22.选择课程");
        System.out.println("33.定时抢课");
        System.out.println("44.开始抢课");
        System.out.println("55.暂停抢课");
        System.out.println("66.全体开始定时抢课");
        System.out.println("77.全体暂停定时抢课");
        System.out.println("88.全体开始抢课");
        System.out.println("99.全体暂停抢课");
        System.out.println("0.退出挖田");
        System.out.println("=========================================");

        Scanner keyBoardInput = new Scanner(System.in, "UTF-8");
        while (keyBoardInput.hasNext()) {
            switch (keyBoardInput.nextInt()) {
                case 1:
                    user = register(user);
                    break;
                case 2:
                    user = MysqlUtil.getUser(user);

                    System.out.println("=========================================选择课程=========================================");
                    if (user != null) {
                        user.setUid(0);
                        user.login();

                        HashMap<String, String> classSelects = user.searchClasses();
                        classSelects.entrySet().stream().forEach(x -> System.out.println("课名：" + x.getKey() + "  id:" + x.getValue()));
                        //Arrays.stream(ClassSelects.split("\n")).skip(3).forEach(obj-> System.out.println(obj));
                        System.out.println("=========================================选择抢课模式=========================================");
                        System.out.println("1.列表抢课[单/多]");
                        System.out.println("2.随机抢课");
                        System.out.println("3.全部抢课");
                        if (keyBoardInput.hasNext()) {
                            switch (keyBoardInput.nextInt()) {
                                case 1:
                                    System.out.println("=========================================列表抢课模式=========================================");
                                    System.out.println("请输入要抢课的id");
                                    while (keyBoardInput.hasNext()) {
                                        String classInput = keyBoardInput.next();
                                        if (classInput.equalsIgnoreCase("exit")) {
                                            user.setRobStrategy(RobStrategy.LIST);
                                            break;
                                        }
                                        Optional<Map.Entry<String, String>> courseNameAndId = user.getClassCache().entrySet().stream().filter(
                                                course -> course.getValue().equalsIgnoreCase(classInput)
                                        ).findFirst();

                                        if (courseNameAndId.isPresent()) {
                                            user.getRobClasses().add(classInput);
                                        } else {
                                            System.out.println("你输入的课程id有误! 请重新输入!");
                                        }
                                    }
                                    MysqlUtil.updateUser(user);
                                    user.outPutRobs();
                                    System.out.println("设置成功: 列表抢课模式");
                                    showTable(user);
                                    break;
                                case 2:
                                    System.out.println("=========================================随机抢课模式=========================================");
                                    user.setRobStrategy(RobStrategy.RANDOM);
                                    User finalUser = user;

//                                    Random random = new Random();
//                                    random.nextInt(classSelects.entrySet().size());
                                    //todo not 感觉随机抢课不实用 先不写了
                                    classSelects.entrySet().stream().forEach(x -> finalUser.getRobClasses().add(x.getValue()));
                                    MysqlUtil.updateUser(user);
                                    System.out.println("设置成功: 随机抢课模式");
                                    user.outPutRobs();
                                    showTable(user);
                                    break;
                                case 3:
                                    System.out.println("=========================================全部抢课模式=========================================");
                                    user.setRobStrategy(RobStrategy.ALL);
                                    User finalUser2 = user;
                                    classSelects.entrySet().stream().forEach(x -> finalUser2.getRobClasses().add(x.getValue()));
                                    MysqlUtil.updateUser(user);
                                    user.outPutRobs();
                                    System.out.println("设置成功: 全部抢课模式");
                                    showTable(user);
                                    break;
                            }
                        }

                    }
                    break;
                case 3:
                    user = MysqlUtil.getUser(user);
                    System.out.println("=========================================定时抢课=========================================");
                    user.startTimer();
                    break;
                case 4:
                    //todo 优化的想法 既然一次复用只能800发包 那么我就另开TCP链接 再次复用800
                    user = MysqlUtil.getUser(user);
                    System.out.println("=========================================开始抢课=========================================");
                    user.startRob();
                    break;
                case 5:
                    user = MysqlUtil.getUser(user);
                    System.out.println("=========================================暂停抢体育课=========================================");
                    user.stopTimer();
                    break;
                case 6:
                    System.out.println("=========================================全体开始定时抢课=========================================");
                    users.parallelStream().forEach(x -> x.startTimer());
                    break;
                case 7:
                    System.out.println("=========================================全体结束定时抢课=========================================");
                    if (robMode == 0) {
                        users.parallelStream().forEach(x -> x.stopTimer());
                    }else{

                    }
                    break;
                case 8:
                    System.out.println("=========================================全体开始抢课=========================================");
                    if (robMode == 0) { //体育课
                        users.parallelStream().forEach(x -> x.startRob());
                    } else {
                        users.parallelStream().forEach(user2 -> {
                            if (user2 != null) {
                                MysqlUtil.getUsers(user2).parallelStream().forEach(user3 -> {
                                    user3.login();
                                    user3.testInit();
                                    user3.startRob();
                                });
                            }
                        });
                    }
                    break;
                case 9:
                    System.out.println("=========================================全体结束抢课=========================================");
                    if (robMode == 0) { //体育课
                        users.parallelStream().forEach(x -> x.stopRob());
                    } else {
                        users.parallelStream().forEach(user2 -> {
                            if (user2 != null) {
                                MysqlUtil.getUsers(user2).parallelStream().forEach(user3 -> {
                                    user3.stopRob();
                                });
                            }
                        });
                    }
                    break;
                case 10:
                    System.out.println("=========================全体抢课资源初始化[请提前使用 避免网络不佳]============================");
                    users.parallelStream().forEach(x -> x.preRobs());
                    break;
                case 22:
                    user = MysqlUtil.getUser(user);
                    System.out.println("=========================================选择课程=========================================");
                    if (user != null) {
                        user.setUid(0);
                        user.login();
                        HashMap<String, String> classSelects = user.searchCommonClasses(true);
                        classSelects.entrySet().stream().forEach(x -> System.out.println("课程代码：" + x.getKey() + "  id:" + x.getValue()));
                        System.out.println("=========================================选择抢课模式=========================================");
                        System.out.println("1.列表抢课[单/多]");
                        if (keyBoardInput.hasNext()) {
                            switch (keyBoardInput.nextInt()) {
                                case 1:
                                    System.out.println("=========================================列表抢课模式=========================================");
                                    System.out.println("请输入要抢课的课程代码,输入exit退出输入");
                                    while (keyBoardInput.hasNext()) {
                                        String classCodeInput = keyBoardInput.next();
                                        if (classCodeInput.equalsIgnoreCase("exit")) {
                                            user.setRobStrategy(RobStrategy.LIST);
                                            break;
                                        }
                                        Optional<Map.Entry<String, String>> courseNameAndId = user.getCommonClassCache().entrySet().stream().filter(
                                                course -> course.getKey().equalsIgnoreCase(classCodeInput)
                                        ).findFirst();
                                        if (courseNameAndId.isPresent()) {
                                            System.out.println("classCodeInput:" + classCodeInput);
                                            user.getRobCommonClasses().add(classCodeInput);
                                            System.out.println("已添加: " + classCodeInput);
                                            System.out.println("=============================================");
                                            System.out.println("当前列表: ");
                                            for (String l : user.getRobCommonClasses()) {
                                                System.out.println(l);
                                            }
                                        } else {
                                            System.out.println("你输入的课程id有误! 请重新输入!");
                                        }
                                    }
                                    MysqlUtil.updateUser(user);
                                    user.outPutCommonRobs();
                                    System.out.println("设置成功: 列表抢课模式");
                                    showTable(user);
                                    break;
                            }
                        }
                    }
                    break;

                case 44:
                    user = MysqlUtil.getUser(user);
                    System.out.println("=========================================开始公选课抢课=========================================");
                    if (user != null) {
                        MysqlUtil.getUsers(user).parallelStream().forEach(user2 -> {
                            user2.login();
                            user2.testInit();
                            user2.startRob();
                        });
                    }
                    break;
                case 55:
//                    user = MysqlUtil.getUser(user);
//                    System.out.println("=========================================开始公选课预抢课资源初始化=========================================");
//                    if (user != null) {
//                        user.setUid(0);
//                        user.login();
//                        user.testInit();
//                        user.test();
//                    }
//                    break;
                case 66:
                case 0:
                    System.exit(0);
            }
        }
    }

    synchronized
    public static void main(String[] args){
        //todo 这里还没开始弄多租户系统 因此目前这里算是个人抢课界面 多租户的时候也为个人抢课页面



        User user = null;
        user = MysqlUtil.getUser(user);
        if (user == null) {
            user = register(user);
        } else {
            showTable(user);
        }


    }

//    public static void rob() throws IOException {
//        String bodyContent = "__EVENTTARGET=&__EVENTARGUMENT=&__VIEWSTATE=dDwtMTEzOTE1MzY2MDt0PHA8bDx4bjt6eWRtO1hTTko7eHE7PjtsPDIwMjAtMjAyMTswODAxOzIwMTk7Mjs%2BPjtsPGk8MT47PjtsPHQ8O2w8aTwxPjtpPDU%2BO2k8OD47aTwxMj47aTwxNz47aTwyMT47PjtsPHQ8cDxwPGw8VGV4dDs%2BO2w85a2m5Y%2B3OjE5MDgwMTAxMDEmbmJzcFw7Jm5ic3BcO%2BWnk%2BWQjTroi4%2FotoXotKQmbmJzcFw7Jm5ic3BcO%2BWtpumZojrorq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ciBteGR4IGxpa2UgJyUsJ3x8J%2BacrOenkTIwMTnnuqforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7vnlLfnlJ8nfHwnLCUnICAgICAgb3IgbXhkeCBsaWtlICclLCd8fCcyMDE557qnJ3x8JywlJyAgICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2Bezuyd8fCcsJScgICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacryd8fCcsJScgICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8JzE56K6h566X5py656eR5a2m5LiO5oqA5pyv77yIMe%2B8ieePrSd8fCcsJScgICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2BeUt%2BeUnyd8fCcsJScgICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8JzIwMTnnuqforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7snfHwnLCUnICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8JzIwMTnnuqforqHnrpfmnLrnp5HlrabkuI7mioDmnK8nfHwnLCUnICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8JzIwMTnnuqfnlLfnlJ8nfHwnLCUnICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2Bezu%2BeUt%2BeUnyd8fCcsJScgICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwn6K6h566X5py656eR5a2m5LiO5oqA5pyv55S355SfJ3x8JywlJyAgICAgICAgb3IgbXhkeCBsaWtlICclLCd8fCcxOeiuoeeul%2BacuuenkeWtpuS4juaKgOacr%2B%2B8iDHvvInnj63nlLfnlJ8nfHwnLCUnICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8JzIwMTnnuqforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7vnlLfnlJ8nfHwnLCUnICAgICAgb3IgbXhkeCBsaWtlICclLCd8fCcyMDE557qn6K6h566X5py656eR5a2m5LiO5oqA5pyv55S355SfJ3x8JywlJyAgICBvciBteGR4IGxpa2UgJyUsJ3x8JzIwMTnnuqcnfHwnLCUnICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwn6K6h566X5py656eR5a2m5LiO5oqA5pyv57O7J3x8JywlJyAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacryd8fCcsJScgICAgICAgb3IgbXhkeCBsaWtlICclLCd8fCcxOeiuoeeul%2BacuuenkeWtpuS4juaKgOacr%2B%2B8iDHvvInnj60nfHwnLCUnICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwnMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2Bezuyd8fCcsJScgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwnMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacryd8fCcsJScgICBvciBteGR4IGxpa2UgJyUsJ3x8Jyd8fCcsJScgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwn5pys56eRJ3x8JywlJyAgICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwn5pys56eRMjAxOee6pyd8fCcsJScgICAgICAgb3IgbXhkeCBsaWtlICclLCd8fCfmnKznp5HorqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7snfHwnLCUnICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwn5pys56eRMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2Bezuyd8fCcsJScgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwnMjAxOee6p%2BeUt%2BeUnyd8fCcsJScgICAgICAgb3IgbXhkeCBsaWtlICclLCd8fCforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7vnlLfnlJ8nfHwnLCUnICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2BeUt%2BeUnyd8fCcsJScgICBvciBteGR4IGxpa2UgJyUsJ3x8JzE56K6h566X5py656eR5a2m5LiO5oqA5pyv77yIMe%2B8ieePreeUt%2BeUnyd8fCcsJScgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwnMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2Bezu%2BeUt%2BeUnyd8fCcsJScgICAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8JzIwMTnnuqforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2FnlLfnlJ8nfHwnLCUnICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwn5pys56eR55S355SfJ3x8JywlJyAgICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2BacrOenkTIwMTnnuqfnlLfnlJ8nfHwnLCUnICAgICBvciBteGR4IGxpa2UgJyUsJ3x8J%2BacrOenkeiuoeeul%2BacuuenkeWtpuS4juaKgOacr%2Bezu%2BeUt%2BeUnyd8fCcsJScgICAgICAgb3IgbXhkeCBsaWtlICclLCd8fCfmnKznp5EyMDE557qn6K6h566X5py656eR5a2m5LiO5oqA5pyv57O755S355SfJ3x8JywlJyAgICAgb3IgbXhkeCBsaWtlICclLCd8fCforqHnrpfmnLrnp5HlrabkuI7mioDmnK8nfHwnLCUnICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwnMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacryd8fCcsJScgICAgb3IgbXhkeCBsaWtlICclLCd8fCcnfHwnLCUnICAgICAgIG9yIG14ZHggbGlrZSAnJSwnfHwnMjAxOee6pyd8fCcsJScgICAgb3IgbXhkeCBsaWtlICclLCd8fCforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7snfHwnLCUnICAgICAgKSAgICAgYW5kICh4emR4IGlzIG51bGwgb3IgeHpkeCBub3QgbGlrZSAnJSwnfHwnMTkwODAxMDEwMSd8fCcsJScgICAgICA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6ZHggbm90ICBsaWtlICclLCd8fCcxOeiuoeeul%2BacuuenkeWtpuS4juaKgOacr%2B%2B8iDHvvInnj60nfHwnLCUnICAgICAgIGFuZCB4emR4IG5vdCAgbGlrZSAnJSwnfHwnMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2Bezuyd8fCcsJScgICAgIGFuZCB4emR4IG5vdCAgbGlrZSAnJSwnfHwnMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacryd8fCcsJScgICAgYW5kIHh6ZHggbm90ICBsaWtlICclLCd8fCcnfHwnLCUnICAgICBhbmQgeHpkeCBub3QgIGxpa2UgJyUsJ3x8J%2BacrOenkSd8fCcsJScgICAgICAgICBhbmQgeHpkeCBub3QgIGxpa2UgJyUsJ3x8J%2BacrOenkTIwMTnnuqcnfHwnLCUnICAgICAgIGFuZCB4emR4IG5vdCAgbGlrZSAnJSwnfHwn5pys56eR6K6h566X5py656eR5a2m5LiO5oqA5pyv57O7J3x8JywlJyAgICAgICBhbmQgeHpkeCBub3QgIGxpa2UgJyUsJ3x8J%2BacrOenkTIwMTnnuqforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7snfHwnLCUnICAgICBhbmQgeHpkeCBub3QgICBsaWtlICclLCd8fCcyMDE557qn55S355SfJ3x8JywlJyAgICAgICBhbmQgeHpkeCBub3QgICBsaWtlICclLCd8fCforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7vnlLfnlJ8nfHwnLCUnICAgICBhbmQgeHpkeCBub3QgICBsaWtlICclLCd8fCforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2FnlLfnlJ8nfHwnLCUnICAgIGFuZCB4emR4IG5vdCAgIGxpa2UgJyUsJ3x8JzE56K6h566X5py656eR5a2m5LiO5oqA5pyv77yIMe%2B8ieePreeUt%2BeUnyd8fCcsJScgICAgIGFuZCB4emR4IG5vdCAgIGxpa2UgJyUsJ3x8JzIwMTnnuqforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7vnlLfnlJ8nfHwnLCUnICAgICAgICAgYW5kIHh6ZHggbm90ICAgbGlrZSAnJSwnfHwnMjAxOee6p%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacr%2BeUt%2BeUnyd8fCcsJScgICAgICAgYW5kIHh6ZHggbm90ICAgbGlrZSAnJSwnfHwn5pys56eR55S355SfJ3x8JywlJyAgICAgICBhbmQgeHpkeCBub3QgICBsaWtlICclLCd8fCfmnKznp5EyMDE557qn55S355SfJ3x8JywlJyAgICAgYW5kIHh6ZHggbm90ICAgbGlrZSAnJSwnfHwn5pys56eR6K6h566X5py656eR5a2m5LiO5oqA5pyv57O755S355SfJ3x8JywlJyAgICAgICBhbmQgeHpkeCBub3QgICBsaWtlICclLCd8fCfmnKznp5EyMDE557qn6K6h566X5py656eR5a2m5LiO5oqA5pyv57O755S355SfJ3x8JywlJyAgICAgYW5kIHh6ZHggbm90IGxpa2UgJyUsJ3x8J%2Biuoeeul%2BacuuenkeWtpuS4juaKgOacryd8fCcsJScgICAgICAgYW5kIHh6ZHggbm90ICBsaWtlICclLCd8fCcyMDE557qn6K6h566X5py656eR5a2m5LiO5oqA5pyvJ3x8JywlJyAgICAgYW5kIHh6ZHggbm90IGxpa2UgJyUsJ3x8Jyd8fCcsJScgICAgICAgYW5kIHh6ZHggbm90ICBsaWtlICclLCd8fCcyMDE557qnJ3x8JywlJyAgICAgYW5kIHh6ZHggbm90ICBsaWtlICclLCd8fCforqHnrpfmnLrnp5HlrabkuI7mioDmnK%2Fns7snfHwnLCUnICAgICApICAgOz4%2BOz47Oz47Pj47Pj47Pg%3D%3D&DropDownList1=%CF%EE%C4%BF&ListBox1=04TJ08&ListBox2=4%282020-2021-2%29-04TJ08-1908010101%23%282020-2021-2%29-04TJ08-041735-1&RadioButtonList1=0&button3=%D1%A1%B6%A8%BF%CE%B3%CC";
//        String responseHtml = basicRequest.postWithLoginCookie("/xstyk.aspx?xh=1908010101&xm=%CB%D5%B3%AC%CF%CD&gnmkdm=N121205", bodyContent);
//        Document doc = Jsoup.parse(responseHtml);
//        Elements links = doc.select("script[language]"); //带有href属性的a元素
//        if (links == null || links.size() == 0) {
//            System.out.println("抢课情况: " + "页面重定向301");
//            return;
//        }
//        String resMessage = links.get(0).data();
//        Pattern pattern = Pattern.compile("[\u4e00-\u9fa5]");
//        Matcher matcher = pattern.matcher(resMessage);
//        StringBuilder messageStr = new StringBuilder();
//        while (matcher.find()) {
//            messageStr.append(matcher.group());
//        }
//        if (messageStr.length() > 0) {
//            System.out.println("抢课情况: " + messageStr);
//        } else {
//            System.out.println("抢课情况: " + "匹配不到失败原因");
//        }
//
//    }


}

